<template>
	<view class="con">
		<view class="body">
			<view class="d_box boxshadow">
				<view class="">
					<view class="title">
						<text class="c3">
							康源生活
						</text>
					</view>
					<view class="info">
						<view class="ul ">
							<serve :isDetail="isDetail" :isOrder="isOrder" v-for="item in (orderDetail.order_goods)"
								:goodsItem="item"></serve>
						</view>

					</view>
				</view>
			</view>
		</view>
		<view class="stars">
			<view class="s_label">
				评分
			</view>
			<u-rate :disabled="!isBtn" size="24" :count="count" v-model="value"></u-rate>
		</view>
		<view class="stars">
			<view class="s_label">
				
			</view>
			<u--textarea v-model="content" :disabled="!isBtn" placeholder="请输入评论内容" count ></u--textarea>
		</view>
		<view class="btn_box" v-if="isBtn">
			<u-button text="提交" @click="subBtn" type="error"></u-button>
		</view>
	</view>
</template>

<script>
	import serve from "@/components/serves/servetwo.vue"
	import {
		getOrderDetail,
		evaluate
	} from "@/api/order.js"
	export default {
		data() {
			return {
				order_id: '',
				orderDetail: {},
				count:5,
				value:0,
				content:"",
				isBtn:true
			}
		},
		components: {
			serve
		},
		onLoad(option) {
			console.log(option)
			this.order_id = option.order_id
			console.log(option)
			this.getDetail(option.order_id)
		},
		methods: {
			getDetail(order_id) {
				const data = {
					order_id: order_id
				}
				getOrderDetail(data).then(res => {
					this.orderDetail = res.data.info

				})
			},
			subBtn(){
				const data = {
					level:this.value,
					content:this.content,
					order_id:this.order_id
				}
				evaluate(data).then(res=>{
					uni.showToast({
						title:res.msg,
						duration:2000,
						success:function(){
							setTimeout(function(){
								uni.switchTab({
									url: '/pages/mine/my'
								});
							}, 2000); // 延迟时间设为3000毫秒
						}
					})
					
					this.isBtn = false
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #fff;	
	}
	.con {
		
	}

	@mixin xcxs {
		display: inline-block;
		background-position: 50%;
		background-repeat: no-repeat;
		background-size: 100% auto;
		position: relative;
	}

	.body {
		.flex {
			display: flex;
			align-items: center;
		}

		.boxshadow {
			// border-radius: 10px;
		}

		.d_box {
			width: 100%;
			// padding: 15px 10px;
			// margin-top: 10px;
			background-color: #fff;

			// margin-bottom: 10rpx;
			.l {
				flex: 1;
			}

			.title {
				width: 95%;
				padding: 20rpx 2.5%;
				font-size: 14px;
				color: #333;

			}

			.info {
				width: 95%;
				padding: 20rpx 2.5% 24rpx;
				font-size: 14px;
				// border-top: 1px solid #f4f4f4;

				.i_bottom {
					margin-top: 5px;
					font-size: 12px;

					.icon-dizhi {
						width: 20px;
						height: 20px;
						margin-right: 7px;
						background: url(https://img-cdn.duobashuzi.com/xianggui/img/m_dz.png);
						@include xcxs;
					}

					.icon-dizhi1 {
						width: 40px;
						height: 39px;
						margin-right: 7px;
						background: url(https://img-cdn.duobashuzi.com/xianggui/img/m_dd.png);
						@include xcxs;
					}

					.ib-r {
						flex: 1;

						text {
							display: block;
							color: #333;
							padding: 5rpx 0;
						}
					}
				}

			}
		}

		.address {
			background: url('https://img.duobashuzi.com/xiangguijia/addr_b.png') no-repeat bottom;
			background-size: 100%;
			background-color: #fff;
			margin: 0;
		}

		.f_box {
			// margin-top: 10px;
			background: #fff;

			.ul {
				// padding-top: 5px;
			}

		}

		.ul_row {
			border-top: 1px solid #f4f4f4;
			padding: 20rpx 0;

			.li {
				width: 100%;
				color: #333;
				font-size: 14px;
				text-align: right;

				text {
					color: #fe3b30;
				}
			}

			.col {
				.r {
					.textarea {
						box-sizing: border-box;
						padding: 10px;
						text-align: left;
						font-size: 14px;
						color: #333;
						height: 86px;
						flex: 1;
						width: 100%;
					}
				}
			}
		}

		.o-box {

			// margin-top: 10px;
			.title {
				padding: 15px 10px;
				display: flex;
				justify-content: space-between;
				border-bottom: 0.5px solid #ededed;
			}

			.cont {
				.li_item {
					font-size: 14px;
					color: #333;
					padding: 10px;
					background: #fff;
					display: flex;
					justify-content: space-between;
					margin-bottom: 2rpx;

					.field {
						color: #999;
					}

					.val {
						color: #333;
					}

					.code_num {
						display: flex;
						align-items: center;
					}
				}
			}
		}
	}
	.stars{
		display: flex;
		background-color: #fff;	
		padding: 0 12px;
		font-size: 14px;
		align-items: center;
		margin-bottom: 10px;
		.s_label{
			margin-right: 10px;
		}
	}
	.btn_box{
		width: 85%;
		margin: 80rpx auto 0;
	}
</style>